// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db =cloud.database();

// 云函数入口函数
//发表帖子
exports.main = async (event, context) => {
  const openid = cloud.getWXContext().OPENID
  var subData = event;
  var {content} =event;
 var code= await cloud.callFunction({
    name:"xiangcun_checkSafe",
    data:{
      content,
    },
  })

  if(code.result.errCode==0)
  {
    var _updateTime = new Date().getTime();
    subData.openid = openid;
    subData._updateTime=_updateTime;
    
   return   await db.collection("jf_info").add({
      data:subData,
    })
   
  }
  else
  {
    return code.result
  }

}